let mapRoutes = new Map()

/*
系统管理
  - 用户管理
  - 角色管理
  - 菜单管理
*/
mapRoutes.set('userManage', () =>
  import(/* webpackChunkName: "userManage" */ '../views/settingManage/userManage/index.vue')
)
mapRoutes.set('roleManage', () =>
  import(/* webpackChunkName: "roleManage" */'../views/settingManage/roleManage/index.vue')
)
mapRoutes.set('menuManage', () =>
  import(/* webpackChunkName: "menuManage" */'../views/settingManage/menuManage/index.vue')
)
mapRoutes.set('companyManage', () =>
  import(/* webpackChunkName: "companyManage" */'../views/settingManage/companyManage/index.vue')
)

let routeList = []

const notfound = () => import('../views/404/index.vue')

const routes = [
  // {
  //   path: '/login',
  //   name: 'login',
  //   component: () => import('../views/login/index.vue'),
  //   meta: {
  //     title: '登录',
  //     parentTitle: ''
  //   }
  // },
  // {
  //   path: '/404',
  //   name: '404',
  //   component: () => import('../views/404/index.vue'),
  //   meta: {
  //     title: '404',
  //     parentTitle: ''
  //   }
  // },
  {
    path: '/',
    redirect: '',
    component: () => import('../components/Layout.vue'),
    children: routeList
  }
]

// 处理路由数据，添加动态路由表
function getRoutes(routerData, callback) {
  routerData.forEach(r => {
    r.children.forEach(c => {
      routeList.push({
        path: c.path,
        name: c.name,
        component: mapRoutes.get(c.name) || notfound,
        meta: {
          isComponent: mapRoutes.get(c.name),
          title: c.menuName,
          parentTitle: r.menuName
        }
      })
    })
  })
  routes[0].redirect = routeList[0].path

  callback(routes)
}

export default getRoutes